import 'reflect-metadata'
import { createConnection } from 'typeorm'

export default async function connectionDatabse() {
	const connection = await createConnection({
		type: 'sqlite',
		database: './data/sqlite.db',
		synchronize: true,
		entities: ['dist/entity/**.js'],
		logging: ['query', 'error'],
		logger: 'file',
		migrationsTableName: 'migration_table',
		migrations: [__dirname + '/migrations/*{.js,.ts}'],
		cli: {
			migrationsDir: 'migration'
		}
	})

	return connection
}
